Title Banner

Previous Book Contents Book Index Next

Inside Macintosh: QuickDraw GX Printing Extensions and Drivers /
Chapter 5 - Printing Functions for Message Overrides / Using the Printing Functions


Managing Paper Trays and Their Paper Types

QuickDraw GX allows the user to assign specific paper types to specific paper trays on a printer, as described in Inside Macintosh: QuickDraw GX Printing. You can use the tray-handling functions from within your message overrides to set or determine the paper type associated with each tray.

The paper trays on a printer are either configured or not. If one or more of the trays on the printer has a specific paper type assigned to it, then the trays are configured. If none of the trays has a specific paper type assigned to it, then the trays are unconfigured. You can call the GXGetTrayMapping function to discover if the printer with which your driver is communicating has trays that are configured.

If you need to cycle through the trays on a printer, you can call the GXCountTrays function to discover how many trays the printer has. For example, if you need to find which tray contains a certain paper type, you can call GXCountTrays and use the value it returns to limit your search.

If you want to determine if a certain paper type is in one of the paper trays, you can first call GXGetTrayMapping. If it tells you that the trays are not configured, than you don't need to look any farther. If it tells you that the trays are configured, you can call GXCountTrays to determine how many trays there are, and then loop through the trays.

You can determine the name of each tray by calling the GXGetTrayName function. You can set the paper type that is associated with a tray by calling the GXSetTrayPaperType function, and you can determine which paper type is associated with a tray by calling the GXGetTrayPaperType function.

Listing 5-1 shows how the LaserWriter printer driver fills in the paper-type names in the Printing menu by looping through the paper trays.

Listing 5-1 Looping through the paper trays

for (i = iEnvelopePopUp; i <= iLargePopUp; ++i)
   {
   GetDItem(dPtr, i, &theKind, &theHandle, &box);
   SetCtlMin((ControlHandle) theHandle, 1);
   SetCtlMax((ControlHandle) theHandle, CountMItems(theMenu));
   SetCtlValue((ControlHandle) theHandle, 1);

   /* if you don't have it, hide it*/
   if    (
         ( (i == iEnvelopePopUp) && (!(options & kEnvelopeMask)) )
       ||( (i == iLargePopUp) && (!(options & k500SheetMask)) ) 
         )
      HideDItem(dPtr, i);
   else
      {
      anErr = GXGetTrayPaperType(i-iEnvelopePopUp+1, paper);
      if (anErr == noErr)
         {
         Str31    paperName, menuString;
         short    j;
         
         GXGetPaperTypeName(paper, paperName);
         
         for (j = CountMItems(theMenu); j > 1; --j) 
            {
            GetItem(theMenu, j, menuString);
            if (IUCompString(menuString, paperName) == 0)
               {
               SetCtlValue((ControlHandle) theHandle, j);
               break;
               }
            }
         }
         
      /*
         If you don't have the resource, it is not an error;
         it means that you have a fresh tray setup.
      */
      if (anErr == resNotFound)
         anErr = noErr;
      nrequire(anErr, FailedGetTrayPaperType);
      }

Previous Book Contents Book Index Next

© Apple Computer, Inc.
7 JUL 1996




Navigation graphic, see text links

Main | Page One | What's New | Apple Computer, Inc. | Find It | Contact Us | Help